package com.yanq.liancar.fragment;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.vondear.rxtool.RxSPTool;
import com.yanq.liancar.R;
import com.yanq.liancar.activity.MyCarActivity;
import com.yanq.liancar.activity.MyOBDActivity;
import com.yanq.liancar.base.BaseLazyFragment;

import butterknife.BindView;

/**
 * A simple {@link Fragment} subclass.
 */
public class CMineFragment extends BaseLazyFragment implements View.OnClickListener {


    @BindView(R.id.myCar)
    TextView myCar;
    @BindView(R.id.myOBD)
    TextView myOBD;

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        myCar.setOnClickListener(this);
        myOBD.setOnClickListener(this);
    }
    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
//        mImmersionBar.statusBarDarkFont(false).init();
    }
    @Override
    protected int setLayoutId() {
        return R.layout.fragment_cmine;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.myCar:
                if (!TextUtils.isEmpty(RxSPTool.getString(getContext(), "UserId"))) {
                    Intent intent = new Intent(getContext(), MyCarActivity.class);
                    intent.putExtra("isC", true);
                    startActivity(intent);
                } else {
                    Toast.makeText(getContext(), "请先登陆", Toast.LENGTH_SHORT).show();
                }
                break;
            case R.id.myOBD:
                if (!TextUtils.isEmpty(RxSPTool.getString(getContext(), "UserId"))) {
                    Intent intent1 = new Intent(getContext(), MyOBDActivity.class);
                    startActivity(intent1);
                } else {
                    Toast.makeText(getContext(), "请先登陆", Toast.LENGTH_SHORT).show();
                }
                break;
        }
    }
}
